package com.ns.rmi.client;

import java.rmi.RemoteException;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.ns.rmi.intf.HelloIntf;

public class HelloClient {

	public static void main(String[] args) {
        try {
			Properties prop = new Properties();
			prop.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
			prop.put("java.naming.provider.url", "corbaloc:iiop:localhost:20901/NameService");
			Context ctx = new InitialContext(prop);
			HelloIntf obj = (HelloIntf)ctx.lookup("hello");
			String ret = obj.echo("Me...");
			System.out.println("FROM SERVER : "+ret);
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (NamingException e) {
			e.printStackTrace();
		}
	}
}
